package com.scalesoft.artsync.frontend.renderer;

import java.awt.Component;

import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

import com.scalesoft.artsync.plugins.Plugin;

public class PluginListCellRenderer extends JLabel implements ListCellRenderer {

	private static final long serialVersionUID = -1497065291979776684L;

	@Override
	public Component getListCellRendererComponent(JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {

		if (isSelected) {
            setBackground(list.getSelectionBackground());
            setForeground(list.getSelectionForeground());
        } else {
            setBackground(list.getBackground());
            setForeground(list.getForeground());
        }

		if (value instanceof Plugin) {
			setText(((Plugin)value).getPluginDisplayName());
		} else {
			setText("unknown");
		}
		
		return this;
	}

}
